#include <stdio.h>

#define MAXSIZE 10

struct LinearList
{
  int data[MAXSIZE];
  int length;
};

void InitList(struct LinearList *ll);
void ListInsert(struct LinearList *ll, int i, int e);

int main()
{
  struct LinearList ll;
  InitList(&ll);
  ListInsert(&ll, 3, 3); // 在第几个位置插入元素

  for (int i = 0; i < MAXSIZE; i++)
  {
    printf("data[%d] = %d\n", i, ll.data[i]);
  }

  printf("length = %d\n", ll.length);
  return 0;
}

void InitList(struct LinearList *ll)
{
  for (int i = 0; i < MAXSIZE; i++)
  {
    // init data
    ll->data[i] = 0;
  }

  ll->length = 0;
}

void ListInsert(struct LinearList *ll, int i, int e)
{
  for (int j = ll->length; j >= i; j--)
  {
    ll->data[j] = ll->data[j - 1]; // 将第 i个后的位置后移一位
  }
  ll->data[i - 1] = e;
  ll->length++;
}